package me.chan.netty.rpc.msg;

import lombok.Data;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

@Data
public abstract class Message implements Serializable {

    public static Class<?> getMessageClass(int messageType) {
        return messageClasses.get(messageType);
    }

    private int sequenceId;

    private int messageType;

    public abstract int getMessageType();

    public static final int RpcRequestMessage = 16;
    public static final int RpcResponseMessage = 17;

    private static final Map<Integer, Class<?>> messageClasses = new HashMap<>();

    static {
        messageClasses.put(RpcRequestMessage, RpcRequestMessage.class);
        messageClasses.put(RpcResponseMessage, RpcResponseMessage.class);

    }
}
